//widgets/slideup_panel/slideup_panel.js
function init(content){
  let that = this;
  
  //header中相应的数据
  that.setData({
    winHeight: 0,
    slideup_panel: {
      title: '编辑信息',
      cancel_txt: '取消',
      done_txt: '完成',
      animationData: {},
      isShow : false,
      isIPX  : wx.app.isIPhoneX(),
      show_section: ''
    }
  });
  
  that.showPopPanel = function(show_section, section_title, after_show_cb) {
    
    let win_h = this.data.winHeight;
    if (!win_h) {
      win_h = wx.getSystemInfoSync().windowHeight
    }
    
    let animation = wx.createAnimation({
      duration: 200,
      timingFunction: "linear",
      delay: 0
    });
    
    this.animation = animation;
    animation.translateY(win_h).step();
    this.setData({
      'slideup_panel.animationData': animation.export(),
      'slideup_panel.isShow': true,
      'slideup_panel.title': section_title,
      'slideup_panel.show_section': show_section,
      winHeight:wx.getSystemInfoSync().windowHeight
    });
    setTimeout(function () {
      animation.translateY(0).step();
      this.setData({
        'slideup_panel.animationData': animation.export()
      })
    }.bind(this), 200);
    
    if (typeof(after_show_cb)=='function') {
      after_show_cb.call(this)
    }
  },
  that.hidePopPanel = function(e) {
    let animation = wx.createAnimation({
      duration: 200,
      timingFunction: "linear",
      delay: 0
    });
    this.animation = animation;
    animation.translateY(this.data.winHeight).step();
    this.setData({
      'slideup_panel.animationData': animation.export()
    });
    setTimeout(function () {
      this.setData({
        'slideup_panel.isShow': false
      })
    }.bind(this), 200)
  }
  
}

module.exports = {
  init: init
}